﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Web;
using System.ComponentModel;
using System.Security.Permissions;

namespace Jerkymon.Web
{
    //public class PaginationDesigner : ControlDesigner
    //{
    //    /// <summary>
    //    /// Main function which returns text to draw on design-time surface.
    //    /// </summary>
    //    /// <returns>Design-time text</returns>
    //    public override string GetDesignTimeHtml()
    //    {
    //        if (Component is Pagination)
    //        {
    //            Pagination ctrl = (Pagination)Component;

    //            //if (ctrl.PaginationControlName == String.Empty) return GetEmptyDesignTimeHtml();

    //            //if (ctrl.RenderMode == Pagination.RenderModes.Image
    //            //    && ctrl.ImagesNamePattern == String.Empty) return GetImageNameNotSpecifiedHtml();

    //            if (ctrl.RenderMode == Pagination.RenderModes.GoogleStyle)
    //                return GetDesignRenderTimeHtml(ctrl.RenderMode);

    //            return base.GetDesignTimeHtml();
    //        }
    //        else return "<FONT COLOR='red'>Designed component isn't of type: <b>Pagination</b>.</FONT>";
    //    }

    //    /// <summary>
    //    /// This function returns text for control, when there was nothing to draw.
    //    /// </summary>
    //    /// <returns>Design-time text, when nothing was drawn</returns>
    //    protected override string GetEmptyDesignTimeHtml()
    //    {
    //        return "[Pagination: no <B>Pagination</b> specified.]";
    //    }


    //    /// <summary>
    //    /// This function returns text for control, when there was nothing to draw.
    //    /// </summary>
    //    /// <returns>Design-time text, when nothing was drawn</returns>
    //    protected string GetDesignRenderTimeHtml( Pagination.RenderModes redermodes )
    //    {
    //        switch (redermodes)
    //        {
    //            case Pagination.RenderModes.GoogleStyle:
    //                return "[Pagination: <B>Google Style Paging</b> specified.]";
    //               // break;
    //            default:
    //                return "[Pagination: <B>Google Style Paging</b> specified.]";
    //                //break;
    //        }

    //        return "[Pagination: no <B>Pagination</b> specified.]";
    //    }

    //    protected string GetImageNameNotSpecifiedHtml()
    //    {
    //        return "<b>Pagination ImagesNamePattern</b> property is not specified. You must specify this property to inform control from where to get images.";
    //    }
    //}


    //public class Pagination : System.Web.UI.WebControls.WebControl
    //[AspNetHostingPermission(SecurityAction.Demand,Level = AspNetHostingPermissionLevel.Minimal),AspNetHostingPermission(SecurityAction.InheritanceDemand,Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("Format"),ToolboxData("<{0}:Pagination runat=\"server\"/>")]
    [ToolboxData("<{0}:Pagination runat=\"server\"></{0}:Pagination>")]
    public class Pagination : WebControl, INamingContainer
    {
        const string strCopyrightInfo = "\r\n<!-- Jerkymon control; (c) 2007 by Melvin Petallana [email: melvin@petallana.com] -->\r\n";

        /// <summary>
        /// Pagination render modes.
        /// </summary>
        public enum RenderModes { Normal, Image, Table, GoogleStyle, PrevPaginationNext, PreviousOnly, NextOnly, GotoFirstPrevPaginationNextGotoLast };

        public enum PaginationModes { None, Bold, Bracket, Parenthesis, BoldBracket, BoldParenthesis };

        public enum PaginationActionMode { Redirect, PostBack };

        #region Properties
        /// <summary>
        /// Total Records .
        /// Determines the total number of records.
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(0), Description("Total Records - determines numbers of records.")]
        public int TotalRecords
        {
            get
            {
                object o = ViewState["TotalRecords"];
                return (o == null) ? 0 : (int)o;
            }
            set
            {
                if (value < 0) throw new ArgumentException("Value can't be less than 0.", "TotalRecords");
                ViewState["TotalRecords"] = value;
            }
        }

        /// <summary>
        /// Page Size .
        /// Determines the total number of records.
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(10), Description("Page Size - determines numbers size of records.")]
        public int PageSize
        {
            get
            {
                object o = ViewState["PageSize"];
                return (o == null) ? 10 : (int)o;
            }
            set
            {
                if (value < 0) throw new ArgumentException("Value can't be less than 0.", "PageSize");
                ViewState["PageSize"] = value;
            }
        }

        /// <summary>
        /// Current Page .
        /// Determines the total number of records.
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(1), Description("Current Page - determines current page.")]
        public int CurrentPage
        {
            get
            {
                object o = ViewState["CurrentPage"];
                return (o == null) ? 1 : (int)o;
            }
            set
            {
                if (value < 0) throw new ArgumentException("Value can't be less than 0.", "CurrentPage");
                ViewState["CurrentPage"] = value;
            }
        }

        /// <summary>
        /// Page Number .
        /// Determines the total number of records.
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(5), Description("Page Number - determines numbers of left and right of current index")]
        public int PageNumber
        {
            get
            {
                object o = ViewState["PageNumber"];
                return (o == null) ? 5 : (int)o;
            }
            set
            {
                if (value < 0) throw new ArgumentException("Value can't be less than 0.", "PageNumber");
                ViewState["PageNumber"] = value;
            }
        }

        /// <summary>
        /// Description .
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue("Page {0} of {1}. Record {2}-{3} of {4}."), Description("Description")]
        public string Description
        {
            get
            {
                object o = ViewState["Description"];
                return (o == null) ? "Page {0} of {1}. Record {2}-{3} of {4}." : (string)o;
            }
            set { ViewState["Description"] = value; }
        }

        /// <summary>
        /// Description String Format 
        /// eg 
        /// 1. "Page {0} of {1}" output is Page 1 of 20 note . this one is actual number of pages
        /// 2. "Record {2}-{3} of {4} " output is Record 1-10 of 200 note . this one is actual number of record
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Description String Format eg. (Page {0} of {1}) note. {0} is current page while {1} is the total record.")]
        public string DescriptionFormat
        {
            get
            {
                object o = ViewState["DescriptionFormat"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["DescriptionFormat"] = value; }
        }

        /// <summary>
        /// PagePath .
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Page Path")]
        public string PagePath
        {
            get
            {
                object o = ViewState["PagePath"];
                return (o == null) ? string.Empty : (string)o;
                //return (o == null) ? System.Web.HttpContext.Current.Request.Url.AbsolutePath : (string)o;
            }
            set { ViewState["PagePath"] = value; }
        }

        /// <summary>
        /// QueryStringName .
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue("pn"), Description("Query String Name")]
        public string QueryStringName
        {
            get
            {
                object o = ViewState["QueryStringName"];
                return (o == null) ? "pn" : (string)o;
            }
            set { ViewState["QueryStringName"] = value; }
        }

        /// <summary>
        /// QueryStrings .
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Query Strings - additional query strings")]
        public string QueryStrings
        {
            get
            {
                object o = ViewState["QueryStrings"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["QueryStrings"] = value; }
        }

        /// <summary>
        /// Style .
        /// </summary>
        //[Bindable(true), Category("Data"), DefaultValue(""), Description("Style - control inline style")]
        [Category("Data")]
        public string PaginationStyle
        {
            get
            {
                object o = ViewState["PaginationStyle"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["PaginationStyle"] = value; }
        }

        /// <summary>
        /// CSS
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("CSS - control css class")]
        public string CSS
        {
            get
            {
                object o = ViewState["CSS"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["CSS"] = value; }
        }

        /// <summary>
        /// Previous
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue("Previous"), Description("Previous - Previous text link.")]
        public string Previous
        {
            get
            {
                object o = ViewState["Previous"];
                return (o == null) ? "Previous" : (string)o;
            }
            set { ViewState["Previous"] = value; }
        }

        /// <summary>
        /// Next
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue("Next"), Description("Next - Next text link.")]
        public string Next
        {
            get
            {
                object o = ViewState["Next"];
                return (o == null) ? "Next" : (string)o;
            }
            set { ViewState["Next"] = value; }
        }

        /// <summary>
        /// PreviousCSS
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Previous CSS - Previous CSS class")]
        public string PreviousCSS
        {
            get
            {
                object o = ViewState["PreviousCSS"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["PreviousCSS"] = value; }
        }

        /// <summary>
        /// NextCSS
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Next CSS- Next CSS class.")]
        public string NextCSS
        {
            get
            {
                object o = ViewState["NextCSS"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["NextCSS"] = value; }
        }

        /// <summary>
        /// PreviousStyle
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Previous Style - Previous inline style")]
        public string PreviousStyle
        {
            get
            {
                object o = ViewState["PreviousStyle"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["PreviousStyle"] = value; }
        }

        /// <summary>
        /// NextStyle
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Next Style - Next inline style.")]
        public string NextStyle
        {
            get
            {
                object o = ViewState["NextStyle"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["NextStyle"] = value; }
        }


        /// <summary>
        /// Control Name
        /// </summary>
        [Bindable(true), Category("Data"), DefaultValue(""), Description("Control Object Name - where the object to be postback.")]
        public string ControlName
        {
            get
            {
                object o = ViewState["ControlName"];
                return (o == null) ? string.Empty : (string)o;
            }
            set { ViewState["ControlName"] = value; }
        }

        /// <summary>
        /// Determines control render mode (as Image or as Table).
        /// </summary>
       // [Bindable(true), Category("Data"), DefaultValue(RenderModes.Normal), Description("Determines how control will be rendered.")]
        [Category("Behavior")]
        public RenderModes RenderMode
        {
            get
            {
                object o = ViewState["RenderMode"];
                return (o == null) ? RenderModes.Normal : (RenderModes)o;
            }
            set { ViewState["RenderMode"] = value; }
        }

        /// <summary>
        /// Determines control render mode (as Image or as Table).
        /// </summary>
       // [Bindable(true), Category("Data"), DefaultValue(PaginationModes.None), Description("Determines how control will be rendered.")]
        [Category("Behavior")]
        public PaginationModes PaginationMode
        {
            get
            {
                object o = ViewState["PaginationMode"];
                return (o == null) ? PaginationModes.None : (PaginationModes)o;
            }
            set { ViewState["PaginationMode"] = value; }
        }


        /// <summary>
        ///Determines how control will act.
        /// </summary>
        //[Bindable(true), Category("Data"), DefaultValue(PaginationActionMode.Redirect), Description("Determines how control will act.")]
        public PaginationActionMode PaginationActionModes
        {
            get
            {
                object o = ViewState["PaginationActionMode"];
                return (o == null) ? PaginationActionMode.Redirect : (PaginationActionMode)o;
            }
            set { ViewState["PaginationActionMode"] = value; }
        }

        private string sPagePath
        {
            get
            {
                return PagePath == "" ? System.Web.HttpContext.Current.Request.Url.AbsolutePath : PagePath;
            }
        }

        #endregion

        protected override void OnPreRender(EventArgs e)
        {

        }

        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        /// 
        protected override void Render(HtmlTextWriter output)
        {
            switch (PaginationActionModes)
            {
                case PaginationActionMode.Redirect:
                    RenderPaginationAsRedirect(output);
                    break;
                case PaginationActionMode.PostBack:
                    //RenderPaginationAsPostBack(output);
                    break;
                default:
                    throw new ArgumentException(String.Format(strCopyrightInfo + " Unknown PaginationActionMode ({0}) for control {1}.", RenderMode, ID), "RenderMode=" + RenderMode.ToString());
            }
        }

        protected virtual void RenderPaginationAsRedirect(HtmlTextWriter output)
        {
            string gs = string.Empty;

            switch (RenderMode)
            {
                case RenderModes.GoogleStyle:
                    gs = GoogleStyle(Description, DescriptionFormat, sPagePath, QueryStringName, QueryStrings, PaginationStyle, CSS, PaginationMode, TotalRecords, CurrentPage, PageSize, PageNumber, Previous, PreviousStyle, PreviousCSS, Next, NextStyle, NextCSS, ControlName, PaginationActionModes);
                    break;
                case RenderModes.GotoFirstPrevPaginationNextGotoLast:
                    break;
                case RenderModes.Normal:
                    break;
                case RenderModes.PrevPaginationNext:
                    break;
            }

            output.Write(gs);
        }

        protected virtual string GoogleStyle(string isDescription, string isDescriptionFormat, string isPath, string isQueryIndex, string isQuery, string isStyle, string isCSS, PaginationModes isMode, int isTotalRecord, int isCurrentPage, int isPageSize, int isPageNumber, string isPrevious, string isPreviousStyle, string isPreviousCSS, string isNext, string isNextStyle, string isNextCSS, string isControlName, PaginationActionMode ActionMode)
        {
            StringBuilder pagination = new StringBuilder();
            int numPagesShown = 0; // set left and right
            int t_number_of_record = 0; // set Total Records
            int t_page = 0; // set Total Pages to 0
            int ps = 0; // set Page Size to 0
            int curpage = 0; // set Current Page  to 0
            string doPostbackFormat = "javascript:__doPostBack('{0}','Page${1}')";
            string strPath = isPath;

            numPagesShown = isPageNumber;

            ps = isPageSize;

            curpage = isCurrentPage;

            t_number_of_record = isTotalRecord;

            t_page = t_number_of_record / ps + (t_number_of_record % ps == 0 ? 0 : 1);

            if (t_page < curpage
                || t_page == 0
                || curpage == 0)
            {
                // info hasn't been entered completely yet
                //return isDescription;
                return string.Empty;
            }

            //if (isDescription != string.Empty)
            //    pagination.Append(string.Format(isDescription, curpage.ToString(), t_page.ToString(), t_number_of_record));

            #region Generate Description
            if (curpage < t_page)
            {
                if (curpage == 1)
                {
                    //displayresult = displayresult + "<span class=\"" + isStyle.ToString() + "\">" + curpage.ToString() + "" + separator + "" + (curpage * ps) + "</span>";
                    if (isDescriptionFormat != string.Empty)
                    {
                        pagination.Append(string.Format(isDescriptionFormat, curpage.ToString(), t_page.ToString(), curpage.ToString(), (curpage * ps), t_number_of_record));
                    }
                    else
                    {
                        if (isDescription != string.Empty)
                            pagination.Append(string.Format(isDescription, curpage.ToString(), t_page.ToString(), curpage.ToString(), (curpage * ps), t_number_of_record));
                    }
                }
                else
                {
                    //displayresult = displayresult + "<span class=\"" + isStyle.ToString() + "\">" + ((curpage - 1) * ps + 1) + "" + separator + "" + (curpage * ps) + "</span>";
                    if (isDescriptionFormat != string.Empty)
                    {
                        pagination.Append(string.Format(isDescriptionFormat, curpage.ToString(), t_page.ToString(), ((curpage - 1) * ps + 1), (curpage * ps), t_number_of_record));
                    }
                    else
                    {
                        if (isDescription != string.Empty)
                            pagination.Append(string.Format(isDescription, curpage.ToString(), t_page.ToString(), ((curpage - 1) * ps + 1), (curpage * ps), t_number_of_record));
                    }
                }
            }
            else if (curpage == t_page)
            {
                if (t_page == 1)
                {
                    //displayresult = displayresult + "<span class=\"" + isStyle.ToString() + "\">" + curpage.ToString() + "" + separator + "" + t_number_of_record.ToString() + "</span>";
                    if (isDescriptionFormat != string.Empty)
                    {
                        pagination.Append(string.Format(isDescriptionFormat, curpage.ToString(), t_page.ToString(), curpage.ToString(), t_number_of_record.ToString(), t_number_of_record));
                    }
                    else
                    {
                        if (isDescription != string.Empty)
                            pagination.Append(string.Format(isDescription, curpage.ToString(), t_page.ToString(), curpage.ToString(), t_number_of_record.ToString(), t_number_of_record));
                    }
                }
                else
                {
                    //displayresult = displayresult + "<span class=\"" + isStyle.ToString() + "\">" + ((curpage - 1) * ps + 1) + "" + separator + "" + t_number_of_record.ToString() + "</span>";
                    if (isDescriptionFormat != string.Empty)
                    {
                        pagination.Append(string.Format(isDescriptionFormat, curpage.ToString(), t_page.ToString(), ((curpage - 1) * ps + 1), t_number_of_record.ToString(), t_number_of_record));
                    }
                    else
                    {
                        if (isDescription != string.Empty)
                            pagination.Append(string.Format(isDescription, curpage.ToString(), t_page.ToString(), ((curpage - 1) * ps + 1), t_number_of_record.ToString(), t_number_of_record));
                    }
                }
            }
            #endregion

            // calculate number of links on both left and right sides
            // of the current page
            int pagesLeft = numPagesShown;
            int pagesRight = numPagesShown;
            int pagesShownTotal = (int)Math.Min(2 * numPagesShown + 1, t_page);

            if (curpage <= numPagesShown)
            {
                pagesLeft = curpage - 1;
                pagesRight = pagesShownTotal - pagesLeft - 1;
            }
            else
                if (t_page - curpage <= numPagesShown)
                {
                    pagesRight = t_page - curpage;
                    pagesLeft = pagesShownTotal - pagesRight - 1;
                }

            if (curpage > 1)
            {
                //if (PaginationActionModes == PaginationActionMode.Redirect)
                //    pagination.Append(" " + "<a class=\"" + isStyle.ToString() + "\" href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage - 1) + isQuery.ToString() + "\">" + Previous + "</a>");

                //if (PaginationActionModes == PaginationActionMode.PostBack)
                //    pagination.Append(" " + "<a class=\"" + isStyle.ToString() + "\" href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage - 1) + isQuery.ToString() + "\">" + Previous + "</a>");

                //pagination.Append(" " + "<a class=\"" + isStyle.ToString() + "\" href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage - 1) + isQuery.ToString() + "\">" + Previous + "</a>");

                pagination.Append(" " + "<a ");

                if (isPreviousCSS != string.Empty)
                    pagination.Append("class=\"" + isPreviousCSS + "\" ");
                else
                    if (isCSS != string.Empty)
                        pagination.Append("class=\"" + isCSS + "\" ");

                if (isPreviousStyle != string.Empty)
                    pagination.Append("style=\"" + isPreviousStyle + "\" ");
                else
                    if (isStyle != string.Empty)
                        pagination.Append("style=\"" + isStyle + "\" ");

                switch (ActionMode)
                {
                    case PaginationActionMode.Redirect:
                        pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage - 1) + isQuery.ToString() + "\">");
                        break;
                    case PaginationActionMode.PostBack:
                        if (isControlName != string.Empty)
                            pagination.Append("href=\"" + string.Format(doPostbackFormat, isControlName, Convert.ToString(curpage - 1)) + "\">");
                        else
                            pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage - 1) + isQuery.ToString() + "\">");
                        break;
                }

                pagination.Append(isPrevious + "</a>");
            }

            if (t_number_of_record > ps)
            {
                #region Loop Counter
                // change existing pages without deleting them
                // to avoid blinking
                for (int i = 0; i < Math.Min(pagesShownTotal, t_page); i++)
                {
                    int pageNum = (int)(curpage - pagesLeft + i);
                    if (pageNum == curpage)
                    {
                        pagination.Append(PaginationModeFormat(isMode, pageNum.ToString()));
                    }
                    else
                    {
                        //pagination.Append(" " + "<a class=\"" + isStyle.ToString() + "\" href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + pageNum.ToString() + isQuery.ToString() + "\">" + pageNum.ToString() + "</a>");
                        pagination.Append(" " + "<a ");

                        if (isCSS != string.Empty)
                            pagination.Append("class=\"" + isCSS + "\" ");

                        if (isStyle != string.Empty)
                            pagination.Append("style=\"" + isStyle + "\" ");

                        switch (ActionMode)
                        {
                            case PaginationActionMode.Redirect:
                                pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + pageNum + isQuery.ToString() + "\">");
                                break;
                            case PaginationActionMode.PostBack:
                                if (isControlName != string.Empty)
                                    pagination.Append("href=\"" + string.Format(doPostbackFormat, isControlName, pageNum) + "\">");
                                else
                                    pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + pageNum + isQuery.ToString() + "\">");
                                break;
                        }

                        pagination.Append(pageNum + "</a>");

                    }
                }
                #endregion
            }

            if (curpage < t_page)
            {
                //pagination.Append(" " + "<a class=\"" + isStyle.ToString() + "\" href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage + 1) + isQuery.ToString() + "\">" + "Next" + "</a>");

                pagination.Append(" " + "<a ");

                if (isNextCSS != string.Empty)
                    pagination.Append("class=\"" + isNextCSS + "\" ");
                else
                    if (isCSS != string.Empty)
                        pagination.Append("class=\"" + isCSS + "\" ");

                if (isNextStyle != string.Empty)
                    pagination.Append("style=\"" + isNextStyle + "\" ");
                else
                    if (isStyle != string.Empty)
                        pagination.Append("style=\"" + isStyle + "\" ");

                switch (ActionMode)
                {
                    case PaginationActionMode.Redirect:
                        pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage + 1) + isQuery.ToString() + "\">");
                        break;
                    case PaginationActionMode.PostBack:
                        if (isControlName != string.Empty)
                            pagination.Append("href=\"" + string.Format(doPostbackFormat, isControlName, Convert.ToString(curpage + 1)) + "\">");
                        else
                            pagination.Append("href=\"" + strPath.ToString() + "?" + isQueryIndex.ToString() + "=" + (curpage + 1) + isQuery.ToString() + "\">");
                        break;
                }

                pagination.Append(isNext + "</a>");
            }

            return pagination.ToString();
        }

        #region Before/After Mode Style
        // Bold = BOL
        // Bracket = BRA
        // Parenthesis = PAR
        // Bold Bracket = BBR
        // Bold Parenthesis = BPA
        public static string PaginationModeFormat(PaginationModes modeStyle, string isData)
        {
            string stylemode = "";

            switch (modeStyle)
            {
                case PaginationModes.Bold:
                    stylemode = " <b>" + isData.ToString() + "</b> ";
                    break;
                case PaginationModes.Bracket:
                    stylemode = " [" + isData.ToString() + "] ";
                    break;
                case PaginationModes.Parenthesis:
                    stylemode = " (" + isData.ToString() + ") ";
                    break;
                case PaginationModes.BoldBracket:
                    stylemode = " <b>[" + isData.ToString() + "]</b> ";
                    break;
                case PaginationModes.BoldParenthesis:
                    stylemode = " <b>(" + isData.ToString() + ")</b> ";
                    break;
                default:
                    stylemode = " " + isData.ToString() + " ";
                    break;
            }
            return stylemode;
        }
        #endregion
    }
}
